<%= render :partial => 'admin/products/menu' %>

<%= link_to "Add Category", :controller => 'categories', :action => 'new' -%>
<br/><br/>

<h1>Listing categories</h1>

<div class="breadcrumb-nav">
  <%= link_to "Categories", :action => "list", :id => nil %>
  <% if @parent_category %>
    >
    <%= breadcrumb_nav @parent_category%>
  <% end %>
</div>

<style>
  .breadcrumb-nav {
    font-size: 12px;
    font-weight: bold;
    padding-top: 10px;
    padding-bottom: 10px;
  }
</style>

<table class="admin-report">
  <tr>
    <th width="75%">Name</th>
    <th>Action</th>
  </tr>
  
<% for category in @categories %>
  <tr>
    <td>
      <% if category.children.empty? %>
        <%= category.name %>
      <% else %>
        <%= link_to category.name, :id => category%>
      <% end %>
    </td>
    <td>
      <%= link_to 'Edit', :action => 'edit', :id => category %> | 
      <%= link_to 'Delete', { :action => 'destroy', :id => category }, :confirm => 'Are you sure you want to delete this category?' %>
    </td>
  </tr>
<% end %>
</table>
<%= render :partial => 'shared/paginate', :locals => {:collection => @categories, :options => {}} -%>